Learn R Programming

ibmdbR (version 1.47.1)

idaQuery, idaScalarQuery: Run an SQL query on the database

Description

Use these functions to run any SQL query on the database and put the results into a data.frame.

Usage

idaQuery(..., as.is=TRUE, na.strings = "NA")
idaScalarQuery(..., as.is=TRUE)

Arguments

...
Any number of query parts which are passed to paste.
as.is
Specifies whether the result columns are to be converted using RODBC type conversions (as.is=FALSE) or left unconverted (as.is=TRUE). For more information about RODBC type conversions, see the descriptions of the functions sqlGetResults and type.convert.
na.strings
character vector of strings to be mapped to NA when reading character data.

Value

The idaQuery function returns a data frame that contains the result of the specified query.The idaScalarQuery function returns the result of the specified query coerced to a single scalar value.

Details

All parts of the input query are concatenated with paste(..., sep="") and the result is passed to the database.

Examples

Run this code
## Not run: 
# #idaScalarQuery returns a single value
# v <- idaScalarQuery("SELECT COUNT(*) FROM IRIS")
# 
# #idaQuery returns a data.frame
# df <- idaScalarQuery("SELECT * FROM IRIS")
# 
# #idaQuery and idaScalarQuery automatically paste all arguments into a single query
# #This is convenient if you use variables
# 
# tableName <- "IRIS"
# df <- idaQuery("SELECT COUNT(*) FROM ",tableName)
# ## End(Not run)

Run the code above in your browser using DataLab